package com.snail.test.utils;

import com.alibaba.fastjson.JSON;

import java.sql.*;

/**
 * @description: TODO
 */
public class JDBCConnect {


    private static final String DRIVER_NAME = "com.aliyun.odps.jdbc.OdpsDriver";

    public static void main(String[] args) throws SQLException {
        try {
            Class.forName(DRIVER_NAME);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
            System.exit(1);
        }

        Connection conn = DriverManager.getConnection(
                "jdbc:odps:http://service.odps.aliyun.com/api?project=DAT_ANALYSIS_dev",
                "LTAI4G37hDGSX4gNkCJhtbD8", "ob4rceTHFFxLJ2u1S4idXVjUT7XXgW");


        // create a table
        Statement stmt = conn.createStatement();

        stmt.executeQuery("SELECT * FROM ads_avalon_production_scheduling_nowstock_df_5m");


        ResultSet rset = stmt.getResultSet();
        while (rset.next()) {
            System.out.println(String.valueOf(rset.getInt(1)) + "\t" + rset.getString(2));
        }
        stmt.close();
        conn.close();
    }
}
